﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using Telerik.Web.UI;

namespace RN.ERP.Web.PersonChange
{
    public partial class PersonCertDetail : BasePage
    {
        /// <summary>
        /// 页面编辑状态
        /// </summary>
        protected int EditStatus
        {
            get;
            set;
        }
        /// <summary>
        /// 用户类型
        /// </summary>
        protected string UserRole
        {
            get
            {
                return UserInfo.RoleType;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetParams();
                CheckEmpManualIsExist();
            }
        }
        public override bool IsCheckPermission
        {
            get { return false; }
        }
        /// <summary>
        /// 取得参数
        /// </summary>
        private void GetParams()
        {
            Guid empGuid = Guid.Empty;
            if (!string.IsNullOrEmpty(Request.QueryString["objectId"]))
            {
                Guid.TryParse(Request.QueryString["objectId"], out empGuid);
            }
            hdEmpGuid.Value = empGuid.ToString();
            if (Request.QueryString["objectName"] != null)
            {
                hdName.Value = lblempName.Text = Request.QueryString["objectName"];
            }
            if (Request.QueryString["corpName"] != null)
            {
                hdCorpName.Value = lblCorpName.Text = Request.QueryString["corpName"];

            }
            if (Request.QueryString["objectType"] != null)
            {
                hidobjectType.Value = Request.QueryString["objectType"].ToString();
            }
            hdCorpGuid.Value = UserInfo.CorpUserGuid.ToString();
            HdAreaCode.Value = UserInfo.CurrentArea;
        }

        /// <summary>
        /// 判断是否显示人员手册并取得人员手册标识
        /// </summary>
        private void CheckEmpManualIsExist()
        {
            if (hidobjectType.Value.Trim() == "5")
            {
                lblTitle.Text = "人员资格证书";
                lblChildTitle.InnerText = "人员资格证书";
                return;
            }
            using (PersonService.PersonServiceClient client = new PersonService.PersonServiceClient())
            {
                var result = JsonConvert.DeserializeObject<ModelService.OperationResult>(client.CheckEmpManualIsExist(UserInfo.CorpUserGuid, hdEmpGuid.Value.Trim(), "ZGZS", HdAreaCode.Value.Trim()));
                if (result.Result)
                {
                    hdManual.Value = result.ReturnValue.ToString();
                }
            }
        }
    }
}